package org.bl.chat.controller;

import lombok.Cleanup;
import org.apache.catalina.User;
import org.bl.chat.common.dto.Response;
import org.bl.chat.model.po.UserDO;
import org.bl.chat.service.UserService;
import org.bl.chat.util.IpUtil;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

@RestController
@RequestMapping("user")
public class UserController {

    @Resource
    private UserService userService;
    @GetMapping("/getUser")
    public Response<UserDO> getUserInfo(HttpServletRequest request) {
        String clientIp = IpUtil.getClientIp(request);
        UserDO user = userService.getUser(clientIp);
        return Response.ok(user);
    }

}
